package com.iflytek.autoCompareTool;

import com.iflytek.autoCompareTool.common.Config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * @author llchen12
 * @date 2018/5/30
 */
public class AutoCompareToolApplication {

    private static Logger logger = LoggerFactory.getLogger(AutoCompareToolApplication.class);

    public static void main(String[] args) throws InterruptedException {

        String confPath;
        if (args.length<1){
            confPath="config.properties";
        }else {
            confPath=args[0];
        }
        System.out.println("使用配置文件-->"+confPath);
        Properties conf=loadConfiguration(confPath);
        Config.init(conf);
        System.out.println("自动化测试工具已成功启动！！！");
        Thread.currentThread().join();

    }

    private static Properties loadConfiguration(String filePath) {
        try (FileInputStream fis = new FileInputStream(filePath)) {
            Properties prop = new Properties();
            prop.load(fis);
            return prop;
        } catch (IOException e) {
            logger.error("加载配置文件失败", e);
            return null;
        }
    }
}
